import { computed } from 'vue'
import { RfcActivityAwardList } from '@/enums'
// import { useRouter } from 'vue-router'
// import { bus } from '@/utils'
import { useAppStore, useProfileStore, useWalletStore } from '@/store'

// export const useAward = (isRfc: boolean, leave: any) => {
export const useAward = () => {
	const store = useAppStore()
	const profileStore = useProfileStore()
	const walletStore = useWalletStore()
	// const isRouterKyc = inject('isRouterKyc', false)
	const isUSDTUser = computed(() => store.isUsdt)
	const buttonList = computed(() => {
		const list = RfcActivityAwardList.slice()
		if (isUSDTUser.value) {
			return list.filter((item) => item.key !== 'mobile')
		}
		return list
	})

	const showStatus = (key: string) => {
		const email = profileStore.userInfo?.email
		const realName = profileStore.userInfo?.realName
		const birthday = profileStore.userInfo?.birthday
		const mobile = profileStore.userInfo?.mobile
		if (mobile && realName && birthday && mobile) {
			walletStore.setWithdrawValidateShow(false)
			return false
		}
		switch (key) {
			case 'mobile':
				return !!mobile
			case 'email':
				return !!email
			case 'realName':
				return !!realName
			case 'birthday':
				return !!birthday
		}
	}

	// const router = useRouter()
	const finish = () => {
		console.log('finish')
		profileStore.setBindingPopupShow(true)
		// if (!isRfc) {
		// 	return router.push(path)
		// }
		// // path可能带有type参数
		// const to = router.resolve(path)
		// if (!isRouterKyc) {
		// 	to.query.isFromAward = '1'
		// }
		// return router
		// 	.push(to)
		// 	.then((err) => {
		// 		if (!err) {
		// 			leave?.()
		// 			bus.$emit('showActivityHome', false)
		// 		}
		// 	})
		// 	.catch(console.error)
	}

	return {
		buttonList,
		showStatus,
		finish
	}
}
